<?php
namespace app\admin\controller\customer;
use app\admin\controller\Controller;
use think\Db;
use think\Session;
/**
 * 客户管理
 * Class Store
 * @package app\admin\controller
 */
class Customer extends Controller{
    /**
     * 客户列表
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function index(){
        $datatype=input('get.datatype');
        if($datatype){
            $where['datatype']=['=',$datatype];
        }
        $search=input('get.search');
        if($search){
            $where['name']=['like','%'.$search.'%'];
        }
        $userinfo=Db::name('love_admin_user')->where(['id'=>Session::get('yoshop_admin')['user']['id']])->find();
        //楼管管理人员
        $user=Db::name('love_admin_user')->where(['areaid'=>$userinfo['areaid'],'type'=>6])->select()->toArray();
        $ids=[];
        if($user){
            foreach ($user as $k=>$v){
                $ids[]=$v['id'];
            }
        }
        $ids[]=$userinfo['id'];
        $where['inputuserid']=['in',$ids];
        $where['inputusertype']=['=',6];

        $list=Db::name('love_customer')->where($where)->order('create_time desc')->paginate(15, false, [
            'query' => \request()->request()
        ]);
        return $this->fetch('index', compact('list'));
    }
}